from flask_wtf import FlaskForm
from wtforms import SubmitField,MultipleFileField
from wtforms.validators import DataRequired
from flask_wtf.file import FileAllowed,FileField,FileRequired


class UploadForm(FlaskForm):
    # render_kw= "accept" 启用h5前端选择文件类型,但最主要的还是要通过服务器端校验 FileAllowed
    photo = FileField('图片',validators=[FileRequired(),FileAllowed(['jpg','png','jpeg','ico'])],render_kw={"accept":".jpg, .png, .jpeg, .ico"})
    submit =SubmitField("上传")


class MultiUploadForm(FlaskForm):
    # render_kw= "accept" 启用h5前端选择文件类型,但最主要的还是要通过服务器端校验 FileAllowed
    friends = MultipleFileField('朋友图片',validators=[DataRequired()])
    submit =SubmitField("上传")